package
{
	import comp.Label;
	import comp.style.StyleManager;
	
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	import rickyGame.controller.Controller;
	import rickyGame.game.GameState;
	import rickyGame.model.User;
	import rickyGame.model.config.*;
	import rickyGame.net.SocketProxy;
	import rickyGame.net.WorkQueue;
	import rickyGame.ui.UIManager;
	import rickyGame.ui.loading.Loading;

	/**
	 * 游戏入口
	 */
	[SWF(backgroundColor="#000000")]
	public class Game extends Sprite
	{
//		[Embed(source="config\\language\\lan",mimeType="application/octet-stream")]
//		public static var language:Class;
		
		public function Game()
		{
			super();
//			JDebug.monitor(stage, 1000);
			if(stage)
			{
				stage.scaleMode=StageScaleMode.NO_SCALE;
				stage.align=StageAlign.TOP_LEFT;	
				stage.frameRate=60;
			}
			this.addEventListener(Event.ADDED_TO_STAGE,init);
		}
		
		/**
		 * 初始化
		 */
		public function init(e:Event=null):void
		{
			
			this.removeEventListener(Event.ADDED_TO_STAGE,init);
			//解析语言包
//			setInfo("解析语言包");
//			CLocale.loadLanguage(new language().toString());
			//加载ui主题文件
			setInfo("加载ui主题文件");
			StyleManager.getInstance().loadCss([new ThemeRegister()]);	
			//加载配置文件
//			setInfo("加载配置文件");
//			GameUnitHelper.init();
			
			GameState.inst.init(this);
			setInfo("初使化游戏状态");
//			SocketProxy.connect("127.0.0.1",9001);

			Controller.instance.init(this.stage);
			
			addChild(new Stats());
			
			UIManager.inst.loading=loading;
			loading.parent.removeChild(loading);
			
			GameState.inst.welcome();
		}
		
		public function setInfo(value:String):void
		{
			if(loading)
				loading.info=value;
//			else
//				JDebug.trace(value);
		}
		
		public var loading:Loading;
	}
}